package bll;

import java.io.File;

public class FileBll {

	public static String findFile(String dirPath, int id) {
		File dir = new File(dirPath);
		String filePath = findFile(dir, id);
		return filePath;
	}

	public static String findFile(File dir, int id) {
		File[] files = dir.listFiles();
		for (File file : files) {
			if (file.isFile()) {
				if (file.getName().startsWith(Integer.toString(id) + "_")) {
					return file.getAbsolutePath();
				}
			}
		}

		for (File file : files) {
			if (file.isDirectory()) {
				String filePath = findFile(file, id);
				if (filePath != null) {
					return filePath;
				}
			}
		}

		return null;
	}

}